//
//  ChartUtils.m
//  ChartDemoX
//
//  Created by yuanpt on 17/5/6.
//  Copyright © 2017年 yuanpt. All rights reserved.
//

#import "ChartUtils.h"

@implementation ChartUtils

+ (void)drawText:(CGContextRef)context text:(NSString *)text point:(CGPoint)point align:(NSTextAlignment)align attributes:(NSDictionary *)attributes {
    CGPoint tempPoint = point;
    if (NSTextAlignmentCenter == align) {
        tempPoint.x -= [text sizeWithAttributes:attributes].width * 0.5;
    } else if (NSTextAlignmentRight == align) {
        tempPoint.x -= [text sizeWithAttributes:attributes].width;
    }
    
    UIGraphicsPushContext(context);
    
    [text drawAtPoint:tempPoint withAttributes:attributes];
    
    UIGraphicsPopContext();
}

+ (void)drawLine:(CGContextRef)context startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint {
    
    UIGraphicsPushContext(context);
    CGContextMoveToPoint(context, startPoint.x, startPoint.y);
    CGContextAddLineToPoint(context, endPoint.x, endPoint.y);
    CGContextStrokePath(context);
    UIGraphicsPopContext();
}

@end
